package jdir.dialog;

import static jdir.util.LogUtil.begin;
import static jdir.util.LogUtil.end;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JPanel;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * This is a group of buttons which will be placed under the FileList.
 * This button group can have two orientations. 
 * @author Marco Peroverde
 */
@SuppressWarnings("unused")
public class ToolBarPanel extends JPanel
{
	private static Log				LOG			= LogFactory.getLog(ToolBarPanel.class);
	private static Boolean			DEBUG		= LOG.isDebugEnabled();	
	private static Boolean			TRACE		= LOG.isTraceEnabled();
	
	private static final long	serialVersionUID	= -8892565576433304435L;
	
	/**
	 * Generates the toolbar which will be placed below the filelists.
	 * @param leftOriented If true the toOtherList button will be the first Button in row. 
	 * Otherwise it will be the last.
	 */
	public ToolBarPanel(Boolean leftOriented, int width, int height)
	{
		if(DEBUG)
			begin(LOG, leftOriented);
		//this.setPreferredSize(new Dimension(width, height));
		
		this.setLayout(new GridLayout(1,5));
		//this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
		width-=10;
		
		
		int fill = this.getWidth() - ((Math.round(this.getWidth()/5)-0) * 5); 
		//TODO Of cause the buttons all need an actionlistener...
		
		JButton filter = new JButton("O");
		//filter.setPreferredSize(new Dimension((Math.round(width/5)-0), height));
		
		JButton root = new JButton("\\");
		//root.setPreferredSize(new Dimension((Math.round(width/5)-0), height));
		
		JButton back = new JButton("<");
		//back.setPreferredSize(new Dimension((Math.round(width/5)-0), height));
		
		JButton forward = new JButton(">");
		//forward.setPreferredSize(new Dimension((Math.round(width/5)-0), height));
		
		JButton toOtherList = leftOriented ? new JButton("<<") : new JButton(">>");
		//toOtherList.setPreferredSize(new Dimension((Math.round(width/5)-0), height));
		
		//Depending of the orientation the toOtherList button will be first or last 
		if(leftOriented)
		{
			this.add(toOtherList);
			this.add(back);
			this.add(forward);
			this.add(root);
			this.add(filter);
		}
		else
		{
			this.add(filter);
			this.add(root);
			this.add(back);
			this.add(forward);
			this.add(toOtherList);	
		}
		
		if(DEBUG)
			end(LOG, "");
	}

}
